﻿using Prism.Events;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using 基于WPF的电缆采样数据分析系统.MsgEvents.Login;

namespace 基于WPF的电缆采样数据分析系统.Views.Users
{
    /// <summary>
    /// LoginUC.xaml 的交互逻辑
    /// </summary>
    public partial class LoginUC : UserControl
    {

        // 发布订阅
        private readonly IEventAggregator Aggregator; // 事件聚合器

        public LoginUC()
        {
            InitializeComponent();

            Aggregator = App.GetService<IEventAggregator>();
            Aggregator.GetEvent<MsgLoginInfo>().Subscribe(Sub);
        }

        /// <summary>
        /// 显示密码内容
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ShowPwdClick(object sender, RoutedEventArgs e)
        {
            ShowPwd.Visibility = Visibility.Visible;
            HiddenPwd.Visibility = Visibility.Collapsed;
        }

        /// <summary>
        /// 隐藏密码内容
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void HiddenPwdClick(object sender, RoutedEventArgs e)
        {
            ShowPwd.Visibility = Visibility.Collapsed;
            HiddenPwd.Visibility = Visibility.Visible;
        }

        /// <summary>
        /// 执行的业务
        /// </summary>
        /// <param name="obj">接收订阅的消息</param>
        private void Sub(string obj)
        {
            RegLoginBar.MessageQueue.Enqueue(obj);
        }
    }
}
